package com.wang.employeemanager;

import java.util.ArrayList;
import java.util.Iterator;

public class EmployeeManager {
    public static void main(String[] args) {
        ArrayList<Employee> arrayList = new ArrayList<>();
        arrayList.add(new Employee(1,"张三",18,3000));
        arrayList.add(new Employee(2,"李四",25,3500));
        arrayList.add(new Employee(3,"王五",22,3200));
        showArrayListInfo(arrayList);
        int index = -1;
        for (int i = 0; i < arrayList.size(); i++) {
            Employee employee = arrayList.get(i);
            if (employee.getName().equals("李四")){
                index = i;
                break;
            }
        }
        arrayList.add(index,new Employee(4,"赵六",24,3300));
        System.out.println("------------------------------");
        showArrayListInfo(arrayList);
        arrayList.remove(3);
        System.out.println("------------------------------");
        showArrayListInfo(arrayList);
        System.out.println("------------------------------");
        Iterator<Employee> iterator = arrayList.iterator();
        while (iterator.hasNext()){
            Employee employee = iterator.next();
            employee.work();
        }
    }

    public static void showArrayListInfo(ArrayList<Employee> arrayList){
        for (int i = 0; i < arrayList.size(); i++) {
            Employee employee = arrayList.get(i);
            System.out.println(employee.getJobNum() + "\t\t" + employee.getName() + "\t\t" + employee.getAge() + "\t\t" + employee.getSalary());
        }
    }

}
